package com.kky.pp.activity.member

import android.view.LayoutInflater
import android.view.View
import android.widget.ImageView
import android.widget.TextView
import com.custom.base.util.IntentUtil
import com.gyf.immersionbar.ImmersionBar
import com.kky.pp.App
import com.kky.pp.R
import com.kky.pp.base.TitleMvpBaseActivity
import com.kky.pp.entity.BuyResultEnum
import com.kky.pp.common.MemberBuy
import com.kky.pp.util.setClick
import com.kky.pp.activity.member.album.PrivateAlbumActivity
import com.kky.pp.databinding.ActivityPrivateAlbumBinding

class BuyPrivateAlbumActivity :
    TitleMvpBaseActivity<BuyPrivateAlbumContract.View, BuyPrivateAlbumPresenter,ActivityPrivateAlbumBinding>(ActivityPrivateAlbumBinding::inflate) {
    val PRIVATE_ALBUM_RESULT_CODE = 201
    override fun bindLayout(): Int {
        return R.layout.activity_private_album
    }

    override fun setFullScreen(): Boolean {
        return true
    }

    override fun isShowBack(): Boolean {
        return true
    }

    override fun setTitle(): String {
        return App.app?.resources?.getString(R.string.private_album)!!
    }

    override fun initView() {
        val isMember = intent.getBooleanExtra("isMember", false)
//        tvOwnPrivateAlbum.setBackgroundResource(if (isMember) R.drawable.shape_solid_black_radius_24 else R.drawable.shape_solid_yellow_radius_24)
        viewBinding.txtOwnSecretAlbum.text =
            (if (isMember) getString(R.string.add_photo) else getString(R.string.own_private_album))
        viewBinding.txtMemberSecretAlbumTip.visibility=if (isMember) View.INVISIBLE else View.VISIBLE
        viewBinding.txtOwnSecretAlbum.setClick {
            if(isMember){
                IntentUtil.startActivity(PrivateAlbumActivity::class.java)
            }else{
                MemberBuy().openMemberBuy(this@BuyPrivateAlbumActivity, 5, 1, callBackListener = {
                    if (it == BuyResultEnum.SUCCESS) {
                        setResult(PRIVATE_ALBUM_RESULT_CODE)
                        mPresenter?.onBackClick()
                    }
                })
            }

        }
    }

    override fun onResume() {
        super.onResume()
        ImmersionBar.with(this@BuyPrivateAlbumActivity).statusBarDarkFont(false).init()
    }

    override val tvMiddleTitle: TextView?
        get() = viewBinding.viewTitle.tvMiddleTitle
    override val tvRightTitle: TextView?
        get() = viewBinding.viewTitle.tvRightTitle
    override val ivLeftImage: ImageView?
        get() = viewBinding.viewTitle.ivBackIcon
    override val viewStatusHeight: View?
        get() = viewBinding.viewTitle.viewStatusHeight


}